import http from "../index";

const baseUrl = 'max-core/api'

export interface IAppDoc {
    code: string;
    name: string;
    type: string;
    version: string;
    appControllers: IAppController[];
}

export interface IAppController {
    code: string;
    name: string;
    prefix: string[];
    apiDefinitions: IApiDefinition[];
}

export interface IApiDefinition {
    code: string;
    name: string;
    path: string;
    url: string;
    method: string;
    rule: string;
    timeFilter: string;
    timeSet: string;
    apiParameters: any[];
}

export interface IApiRequest {
    url: string;
    method: string;
    params: any;
    data: any;
}

export const getAppDoc = () => {
    return http.request<IAppController[]>({url: baseUrl})
}

export const sendApiRequest = (apiRequest: IApiRequest) => {
    return http.request({method: apiRequest.method, url: apiRequest.url, params: apiRequest.params, data: apiRequest.data})
}